package cn.com.chengmandian.sls.utils;

import cn.com.chengmandian.sls.constants.AutoLogType;
import cn.com.chengmandian.sls.pojo.AutoLogData;

public class AutoLogBuilder {
    public static AutoLogBuilder instance;

    public static AutoLogBuilder me() {
        if (instance == null) instance = new AutoLogBuilder();
        return instance;
    }

    // 其它消息输出
    public String other(String message) {
        return new AutoLogData()
                .setType(AutoLogType.OTHER.name())
                .setMessage(message)
                .toString();
    }

    // 其它消息输出
    public String exception(String message) {
        return new AutoLogData()
                .setType(AutoLogType.EXCEPTION.name())
                .setMessage(message)
                .toString();
    }

    public String write(String task, Integer agentId, Integer areaId, String message) {
        return this.write(task, AutoLogType.OTHER, agentId, areaId, message);
    }

    public String write(String task, Integer agentId, String message) {
        return this.write(task, AutoLogType.OTHER, agentId, message);
    }

    public String write(String task, String message) {
        return this.write(task, AutoLogType.OTHER, message);
    }

    public String write(String task, AutoLogType autoLogType, Integer agentId, Integer areaId, String message) {
        return new AutoLogData()
                .setTask(task)
                .setType(autoLogType.name())
                .setAgentId(agentId)
                .setAreaId(areaId)
                .setMessage(message)
                .toString();
    }

    public String write(String task, AutoLogType autoLogType, Integer agentId, String message) {
        return new AutoLogData()
                .setTask(task)
                .setType(autoLogType.name())
                .setAgentId(agentId)
                .setMessage(message)
                .toString();
    }

    public String write(String task, AutoLogType autoLogType, String message) {
        return new AutoLogData()
                .setTask(task)
                .setType(autoLogType.name())
                .setMessage(message)
                .toString();
    }

    public String taskEnd(String task, Integer agentId, Integer areaId, String message, long timeLast) {
        return new AutoLogData()
                .setTask(task)
                .setType(AutoLogType.TASK_END.name())
                .setAgentId(agentId)
                .setAreaId(areaId)
                .setMessage(message)
                .setTimeLast(timeLast)
                .toString();
    }
}
